package workquene;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;
import org.junit.Test;
import utils.ConnectionUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author xj
 * @create 2021/8/12 11:30
 */
public class Provider {

    @Test
    public void providerTest() throws IOException, TimeoutException {

        Connection connection = ConnectionUtils.getConnection("localhost", 5672, "/xj", "xj", "123");
        Channel channel = connection.createChannel();

        channel.queueDeclare("work", true, false, false, null);
        for (int i = 0; i < 10; i++) {
            channel.basicPublish("", "work", MessageProperties.PERSISTENT_TEXT_PLAIN, (i + "work quene").getBytes());
        }

        channel.close();
        connection.close();
    }
}
